package com.water.schedule;

import com.utils.bean.EmailDTO;
import com.utils.util.MailSend;
import com.water.config.YmlPropertySourceFactory;
import com.water.utils.RemindUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.swing.*;

@Component
@PropertySource(value = "classpath:schedule.yml", factory = YmlPropertySourceFactory.class)
public class WaterSchedule {

    @Autowired
    private MailSend mailSend;

    @Scheduled(cron = "${schedule.water.cron}")
    public void waterTip()
    {
        try{
            RemindUtil reminUtil = new RemindUtil();
            reminUtil.VersionUtil();
//            EmailDTO param = new EmailDTO();
//            param.setTargetAddress(new String[]{"zhangchaohuiget@163.com"});
//            param.setSubject("该喝水了");
//            param.setText("去喝水！");
//            mailSend.sendNormalEmail(param);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
